package d1118.r214.num07;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
//工具类
public class Tools {
    //计算平均分
    public static double getAvg(List<Student> list){
        double sum=0;
        //计算平均分
        Iterator<Student> it=list.iterator();
        while(it.hasNext()){
            Student stu=it.next();
            sum+=stu.getScore();
        }

        return sum/list.size();

    }
    //最高分
    public static Student getMax(List<Student> list) {
        Iterator<Student> it=list.iterator();
        Student stuMax=it.next();
        while (it.hasNext()){
            Student stu=it.next();
            if(stu.getScore()>stuMax.getScore()){
                stuMax=stu;
            }

        }
        return stuMax;
    }

    //不及格的方法
    public  static List<Student> getBL60(List<Student> list){
       List<Student> listbl60=new ArrayList<>();
        for(Student stu:list) {
            if(stu.getScore()<60){
                listbl60.add(stu);
            }
        }

        return listbl60;

    }

}
